using UnityEngine;

public class EnemyAttack : MonoBehaviour
{
    [Header("伤害")]
    public int damage;
    [Header("销毁时间")]
    public float desTimer;
    [Header("移动方向")]
    public Vector2 dir;
    [Header("移动速度")]
    public float speed;
    
    //攻击玩家
    public void AttackPlayer()
    {
        GameManager.Instance.ChangePlayerHp(-damage);
        //关闭自身碰撞
        GetComponent<Collider2D>().enabled=false;
        //速度归0
        speed=0;
    }
    //计算销毁
    public  virtual void UpdateDesTimer()
    {
        desTimer-=Time.deltaTime;
        if(desTimer<=0)
        {
            Destroy(gameObject);
        }
    }
    //移动
    public virtual void Move()
    {
        transform.Translate(dir*speed*Time.deltaTime);
    }
    //设置方向
    public void SetDir(Vector2 _dir)
    {
        dir=_dir;
    }
}
